﻿@using SmartSiteManagementSystem.Models.Admin;

@{
     Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.BodyClass = "easyui-layout";
    AdminGroupInfo adminGroupInfo = ViewBag.adminGroupInfo;
}
<div class="easyui-panel" style="padding:5px;">
    <input id="AdminUserGroupId" type="hidden" value="@adminGroupInfo.AdminUserGroupId" />
    <table class="gou-formTable" style="width:600px;align-content:center;">
        <tbody>
            <tr>
                <td align="right" class="gou-formTable-title">*名称</td>
                <td align="left" class="">
                    <input id="AdminUserGroupName" name="AdminUserGroupName" type="text" value="@adminGroupInfo.AdminUserGroupName" />
                </td>
            </tr>
            <tr>
                <td align="right" class="gou-formTable-title">Code</td>
                <td align="left" class="">
                    <input id="Code" name="Code" type="text" value="@adminGroupInfo.Code" />
                </td>
            </tr>            
            <tr>
                <td align="right" class="gou-formTable-title">邮箱</td>
                <td align="left" class="">
                    <input id="Email" name="Email" type="text" value="@adminGroupInfo.Email" />
                </td>
            </tr>
            <tr>
                <td align="right" class="gou-formTable-title">序号</td>
                <td align="left" class="">
                    <input id="SortOrder" name="SortOrder" type="text" value="@adminGroupInfo.SortOrder" />                   

                </td>
            </tr>           
            <tr>
                <td align="right" class="gou-formTable-title">备注</td>
                <td align="left" class="">
                    <input id="Remark" name="Remark" type="text" value="@adminGroupInfo.Remark" />

                </td>
            </tr>

            <tr>
                <td colspan="2" align="center">
                    <a href="javascript:void(0)" id="hfSave" class="easyui-linkbutton" iconcls="icon-save" onclick="SaveAdminGroup();" style="width:150px;height:32px">保存</a>
                </td>
            </tr>
        </tbody>
    </table>

</div>



<script type="text/javascript">

    function ValidateEmail(data) {
        return true;
        @*var emailreg = /\w+[@]{1}\w+[.]\w+/;

            if (!emailreg.test(data)) {
                return true;
            } else {
                return false;
            }*@
    }
   

    //保存
    function SaveAdminGroup() {

        //验证必选项******************************************************************
        var AdminUserGroupName = $("#AdminUserGroupName").val();
        var Code = $("#Code").val();
        var UserType = $("#UserType").val();
        var Email = $("#Email").val();        
        var SortOrder = $("#SortOrder").val();
        var Remark = $("#Remark").val();
        var AdminUserGroupId = $("#AdminUserGroupId").val();

        if (AdminUserGroupName == "") {
            $.messager.alert('提示', '姓名为必填项!');
            return false;
        }       

        if (Email != "") {
            if (!ValidateEmail(Email)) {
                $.messager.alert('提示', '请填写合法邮箱!');
            }
        }
    
        var param = { AdminUserGroupId: AdminUserGroupId, AdminUserGroupName: AdminUserGroupName, Code: Code, Email: Email, SortOrder: SortOrder, Remark: Remark };
        $.ajax({
            "type": "Post",
            "url": "ajaxAccess?t=" + new Date().getTime(),
            "dataType": "text",
            "data": param,
            "success": function (data) {
                if (data == "True") {
                    window.location.href = "index";
                }
            }
        });
    }
</script>
